# -*- coding: utf-8 -*-
from django.conf import settings
from django.conf.urls import include, static
from django.urls import re_path
from idcops import views
from idcops.list import ListModelView, ConfigUserListView
from idcops.detail import DetailModelView
from idcops.edit import NewModelView, EditModelView

app_name = "idcops"


accounts_urls = [
    re_path(r"login/$", views.login, name="login"),
    re_path(r"logout/$", views.logout, name="logout"),
    re_path(r"profile/", views.ProfileView.as_view(), name="profile"),
    re_path(r"password_change/$", views.password_change, name="password_change"),
    re_path(
        r"password_change/done/$",
        views.password_change_done,
        name="password_change_done",
    ),
    re_path(r"password_reset/$", views.password_reset, name="password_reset"),
    re_path(
        r"password_reset/done/$", views.password_reset_done, name="password_reset_done"
    ),
    re_path(
        r"reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$",
        views.reset,
        name="password_reset_confirm",
    ),
    re_path(r"reset/done/$", views.reset_done, name="password_reset_complete"),
]


urlpatterns = [
    re_path(r"$", views.IndexView.as_view(), name="index"),
    re_path(r"accounts/", include(accounts_urls)),
    re_path(r"welcome/", views.welcome, name="welcome"),
    re_path(r"switch_onidc/", views.switch_onidc, name="switch_onidc"),
    re_path(r"list/zonemap/", views.ZonemapView.as_view(), name="zonemap"),
    re_path(r"(?:new/(?P<model>\w+))/$", NewModelView.as_view(), name="new"),
    re_path(r"(?:list/(?P<model>\w+))/$", ListModelView.as_view(), name="list"),
    re_path(
        r"(?:config/(?P<model>\w+))/$", ConfigUserListView.as_view(), name="config"
    ),
    re_path(
        r"(?:config/list/(?P<model>\w+))/$",
        ConfigUserListView.as_view(),
        name="config_list",
    ),
    re_path(
        r"(?:detail/(?:(?P<model>\w+)-(?P<pk>\d+)))/$",
        DetailModelView.as_view(),
        name="detail",
    ),
    re_path(
        r"(?:update/(?:(?P<model>\w+)-(?P<pk>\d+)))/$",
        EditModelView.as_view(),
        name="update",
    ),
    re_path(r"upload/$", views.SummernoteUploadAttachment.as_view(), name="upload"),
    re_path(r"import/(?P<model>\w+)/$", views.ImportExcelView.as_view(), name="import"),
]


if settings.DEBUG:
    urlpatterns += static.static(
        settings.STATIC_URL, document_root=settings.STATIC_ROOT
    )
    urlpatterns += static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
